nethackfandomcom-20200214-history
Source:NetHack 3.1.0/tradstdc.h
Below is the full text to tradstdc.h from the source code of NetHack 3.1.0. To link to a particular line, write [[NetHack 3.1.0/tradstdc.h#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* SCCS Id: @(#)tradstdc.h 3.1 92/04/01 */ 2. /* Copyright © Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #ifndef TRADSTDC_H 6. #define TRADSTDC_H 7. 8. #if defined(DUMB) && !defined(NOVOID) 9. #define NOVOID 10. #endif 11. 12. #ifdef NOVOID 13. #define void int 14. #endif 15. 16. #if defined(__STDC__) && !defined(NOTSTDC) 17. #define NHSTDC 18. #endif 19. 20. #if defined(ultrix) && defined(__STDC__) && !defined(__LANGUAGE_C) 21. /* Ultrix seems to be in a constant state of flux. This check attempts to 22. * set up ansi compatibility if it wasn't set up correctly by the compiler. 23. */ 24. #ifdef mips 25. #define __mips mips 26. #endif 27. 28. #ifdef LANGUAGE_C 29. #define __LANGUAGE_C LANGUAGE_C 30. #endif 31. 32. #endif 33. 34. /* 35. * ANSI X3J11 detection. 36. * Makes substitutes for compatibility with the old C standard. 37. */ 38. 39. /* Decide how to handle variable parameter lists: 40. * USE_STDARG means use the ANSI facilities (only ANSI compilers 41. * should do this, and only if the library supports it). 42. * USE_VARARGS means use the facilities. Again, this should only 43. * be done if the library supports it. ANSI is *not* required for this. 44. * Otherwise, the kludgy old methods are used. 45. * The defaults are USE_STDARG for ANSI compilers, and USE_OLDARGS for 46. * others. 47. */ 48. 49. /* #define USE_VARARGS /* use instead of */ 50. /* #define USE_OLDARGS /* don't use any variable argument facilites */ 51. 52. #if defined(apollo) /* Apollos have stdarg(3) but not stdarg.h */ 53. # define USE_VARARGS 54. #endif 55. 56. #if defined(NHSTDC) || defined(ULTRIX_PROTO) || defined(MAC) 57. # if !defined(USE_VARARGS) && !defined(USE_OLDARGS) && !defined(USE_STDARG) 58. # define USE_STDARG 59. # endif 60. #endif 61. 62. #ifdef NEED_VARARGS /* only define these if necessary */ 63. #ifdef USE_STDARG 64. # include 65. # define VA_DECL(typ1,var1) (typ1 var1, ...) { va_list the_args; 66. # define VA_DECL2(typ1,var1,typ2,var2) \ 67. (typ1 var1, typ2 var2, ...) { va_list the_args; 68. # define VA_INIT(var1,typ1) 69. # define VA_NEXT(var1,typ1) var1 = va_arg(the_args, typ1) 70. # define VA_ARGS the_args 71. # define VA_START(x) va_start(the_args, x) 72. # define VA_END() va_end(the_args) 73. # if defined(ULTRIX_PROTO) && !defined(_VA_LIST_) 74. # define _VA_LIST_ /* prevents multiple def in stdio.h */ 75. # endif 76. #else 77. # ifdef USE_VARARGS 78. # include 79. # define VA_DECL(typ1,var1) (va_alist) va_dcl {\ 80. va_list the_args; typ1 var1; 81. # define VA_DECL2(typ1,var1,typ2,var2) (va_alist) va_dcl {\ 82. va_list the_args; typ1 var1; typ2 var2; 83. # define VA_ARGS the_args 84. # define VA_START(x) va_start(the_args) 85. # define VA_INIT(var1,typ1) var1 = va_arg(the_args, typ1) 86. # define VA_NEXT(var1,typ1) var1 = va_arg(the_args,typ1) 87. # define VA_END() va_end(the_args) 88. # else 89. # define VA_ARGS arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9 90. # define VA_DECL(typ1,var1) (var1,VA_ARGS) typ1 var1; \ 91. char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; { 92. # define VA_DECL2(typ1,var1,typ2,var2) (var1,var2,VA_ARGS) \ 93. typ1 var1; typ2 var2;\ 94. char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; { 95. # define VA_START(x) 96. # define VA_INIT(var1,typ1) 97. # define VA_END() 98. # endif 99. #endif 100. #endif /* NEED_VARARGS */ 101. 102. #if defined(NHSTDC) || defined(MSDOS) || defined(MAC) || defined(ULTRIX_PROTO) 103. 104. /* 105. * Used for robust ANSI parameter forward declarations: 106. * int VDECL(sprintf, (char *, const char *, ...)); 107. * 108. * NDECL() is used for functions with zero arguments; 109. * FDECL() is used for functions with a fixed number of arguments; 110. * VDECL() is used for functions with a variable number of arguments. 111. * Separate macros are needed because ANSI will mix old-style declarations 112. * with prototypes, except in the case of varargs, and the OVERLAY-specific 113. * trampoli.* mechanism conflicts with the ANSI <> syntax. 114. */ 115. 116. # define NDECL(f) f(void) /* Must be overridden if OVERLAY set later */ 117. 118. # define FDECL(f,p) f p 119. 120. # if defined(MSDOS) || defined(USE_STDARG) 121. # define VDECL(f,p) f p 122. # else 123. # define VDECL(f,p) f() 124. # endif 125. 126. /* generic pointer, always a macro; genericptr_t is usually a typedef */ 127. # define genericptr void * 128. 129. # if defined(__TURBOC__) || (defined(ULTRIX_PROTO) && !defined(__GNUC__)) || defined(OS2_CSET2) 130. /* Cover for stupid Turbo C */ 131. /* And Ultrix on a DECstation with 2.0 compiler, which coredumps on 132. * typedef void * genericptr_t; 133. * extern void a(void(*)(int, genericptr_t)); 134. * Using the #define is OK for other compiler versions too. 135. */ 136. /* And IBM CSet/2. The redeclaration of free hoses the compile. */ 137. # define genericptr_t genericptr 138. # else 139. # if !defined(NHSTDC) && !defined(MAC) 140. # define const 141. # define signed 142. # define volatile 143. # endif 144. # endif 145. 146. # if !defined(LATTICE) && !defined(MAC) 147. /* Lattice can't even PARSE the const below! */ 148. /* MPW can parse but expects an identifier, not a keyword... */ 149. # if defined(ULTRIX_PROTO) && !defined(NHSTDC) && !defined(const) 150. # define const /* the system header files are *not* __STDC__ */ 151. # endif 152. # if defined(apollo) && !defined(const) 153. # define const /* too much trouble with printf(char *format, ...) */ 154. # endif /* instead of printf(const char *format, ...) etc. */ 155. # endif 156. 157. #else /* NHSTDC */ /* a "traditional" C compiler */ 158. 159. # define NDECL(f) f() 160. # define FDECL(f,p) f() 161. # define VDECL(f,p) f() 162. 163. # if defined(AMIGA) || defined(HPUX) || defined(POSIX_TYPES) || defined(__DECC) 164. # define genericptr void * 165. # endif 166. # ifndef genericptr 167. # define genericptr char * 168. # endif 169. 170. /* 171. * Traditional C compilers don't have "signed", "const", or "volatile". 172. */ 173. # define signed 174. # define const 175. # define volatile 176. 177. #endif /* NHSTDC */ 178. 179. 180. #ifndef genericptr_t 181. typedef genericptr genericptr_t; /* (void *) or (char *) */ 182. #endif 183. 184. 185. /* 186. * According to ANSI, prototypes for old-style declarations must widen the 187. * arguments to int. However, the MSDOS compilers accept shorter arguments 188. * (char, short, etc.) in prototypes and do typechecking with them. Therefore 189. * this mess to allow the better typechecking while also allowing some 190. * prototypes for the ANSI compilers so people quit trying to fix the 191. * prototypes to match the standard and thus lose the typechecking. 192. */ 193. #if defined(MSDOS) && !defined(__TURBOC__) && !defined(__GO32__) 194. #define UNWIDENED_PROTOTYPES 195. #endif 196. #if defined(AMIGA) && !defined(AZTEC_50) 197. #define UNWIDENED_PROTOTYPES 198. #endif 199. #if defined(MAC) && !defined(THINK_C) 200. #define UNWIDENED_PROTOTYPES 201. #endif 202. 203. #if defined(ULTRIX_PROTO) && defined(ULTRIX_CC20) 204. #define UNWIDENED_PROTOTYPES 205. #endif 206. #if defined(apollo) 207. #define UNWIDENED_PROTOTYPES 208. #endif 209. 210. #ifndef UNWIDENED_PROTOTYPES 211. # if defined(NHSTDC) || defined(__TURBOC__) || defined(ULTRIX_PROTO) || defined(THINK_C) 212. # define WIDENED_PROTOTYPES 213. # endif 214. #endif 215. 216. #if defined(sgi) && !defined(__GNUC__) 217. /* 218. * As of IRIX 4.0.1, /bin/cc claims to be an ANSI compiler, but it thinks 219. * it's impossible for a prototype to match an old-style definition with 220. * unwidened argument types. Thus, we have to turn off all NetHack 221. * prototypes, and avoid declaring several system functions, since the system 222. * include files have prototypes and the compiler also complains that 223. * prototyped and unprototyped declarations don't match. 224. */ 225. # undef NDECL 226. # undef FDECL 227. # undef VDECL 228. # define NDECL(f) f() 229. # define FDECL(f,p) f() 230. # define VDECL(f,p) f() 231. #endif 232. 233. 234. #ifdef __HC__ /* MetaWare High-C defaults to unsigned chars */ 235. # undef signed 236. #endif 237. 238. 239. /* 240. * Allow gcc2 to check parameters of printf-like calls with -Wformat; 241. * append this to a prototype declaration (see pline() in extern.h). 242. */ 243. #ifdef __GNUC__ 244. # if __GNUC__ >= 2 245. #define PRINTF_F(f,v) __attribute__ ((format (printf, f, v))) 246. # endif 247. #endif 248. #ifndef PRINTF_F 249. #define PRINTF_F(f,v) 250. #endif 251. 252. #endif /* TRADSTDC_H */ tradstdc.h